package com.ryskoo.catering.orderdetail.repository;

import com.ryskoo.catering.constant.HCLCacheConstant;
import com.ryskoo.catering.orderdetail.domain.OrderDetailPO;
import com.ryskoo.framework.core.repository.BasicRedisImpl;
import com.ryskoo.framework.core.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Repository;

import javax.annotation.PostConstruct;
import java.util.List;

/**
 * @author BeHappy
 */
@Primary
@Repository
public class OrderDetailRedisImpl extends BasicRedisImpl<OrderDetailPO> implements IOrderDetailRepository {
    @Autowired
    private RedisUtil redisClient;
    @Autowired
    private IOrderDetailRepository orderDetailRepository;

    @PostConstruct
    public void init() {
        this.setRedisClient(redisClient);
        this.setDao(orderDetailRepository);
    }

    public OrderDetailRedisImpl() {
        super(HCLCacheConstant.HCL_ORDERDETAIL_KEY);
    }

    @Override
    public List<OrderDetailPO> getDetailListByOrderUuid(String orderUuid) {
        return orderDetailRepository.getDetailListByOrderUuid(orderUuid);
    }

    @Override
    public List<String> getUuidsByProductUuid(String productUuid) {
        return orderDetailRepository.getUuidsByProductUuid(productUuid);
    }
    @Override
    public List<String> getDetailUuidsByOrderUuid(String orderUuid) {
        return orderDetailRepository.getDetailUuidsByOrderUuid(orderUuid);
    }
}
